<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>


	<div class="bjui-pageContent">
		<table class="table table-bordered" id="application_mana" data-toggle="datagrid"  data-options="{
		height: '100%',
		showToolbar: true,//显示工具栏
		
		toolbarItem: 'edit,|,import,export,exportf',
		gridTitle : '申请审核',//表格名称
		filterThead: false,
		dataUrl: 'http://localhost:8080/LockManagerSystem/json/getRequestList2',//表格数据源
	    dataType: 'json',//数据类型
        local:'remote',//分页显示
        paging:{pageSize:30,pageCurrent:1},
      

      
        linenumberAll: true//显示编号值
		}">
    <thead>
        <tr>
            <th data-options="{name:'customer',align:'center',width:90}">客户</th>

			<th data-options="{name:'count',align:'center',width:90}">请求数量</th>
			<th data-options="{name:'otherName',align:'center',width:100}">备用联系人</th>
			<th data-options="{name:'otherPhone',align:'center',width:150}">备用联系电话</th>
			<th data-options="{name:'date',align:'center',width:150}">请求时间</th>
			<th data-options="{name:'state',align:'center',width:100,type:'select',items:[{0:'待审核'},{1:'审核未通过'}]}">请求状态</th>
			<th data-options="{name:'cCode',align:'center',width:100, hide:true}">客户标识</th>
			<th data-options="{name:'rCode',align:'center',width:100, hide:true}">请求标识</th>
			<th data-options="{name:'tongguo',align:'center',width:100,render:allot_adopt}">审核</th>
			 
        </tr>
    </thead>
      </table>
	</div>
	
	<script type="text/javascript">


function allot_adopt(){
	var html = '<button type="button" class="btn-green" onclick="allot_manage_adopt()" data-icon="edit" >通过</button>';
	return html;
}
function allot_manage_adopt(){
	setTimeout(function () {
		var allocation_ma = $('#application_mana').data('selectedDatas');
		console.log($('#application_mana').data('selectedDatas'));
		BJUI.ajax('doajax',{	
			url:'http://localhost:8080/LockManagerSystem/json/checkRequest',
			data:{rCode:allocation_ma[0].rCode},
			okCallback:allot_adopt_success,
		})
	}, 10);
	
}
function allot_adopt_success(json,options){
	console.log(json.code);
	if(json.code == '211')
		{
			BJUI.alertmsg('info','申请超过库存数量');
		}
	else if(json.code == '210')
		{
			BJUI.alertmsg('info','申请成功');
			$('#application_mana').datagrid('refresh',true);
		}
	
}

</script>